﻿// Decompiled with JetBrains decompiler
// Type: TaleWorlds.MountAndBlade.View.MissionViews.MissionBoundaryWallView
// Assembly: TaleWorlds.MountAndBlade.View, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 61152EB8-513B-4D4A-8AC0-0D1465C6CF6C
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\Modules\Native\bin\Win64_Shipping_Client\TaleWorlds.MountAndBlade.View.dll

using System.Collections.Generic;
using TaleWorlds.DotNet;
using TaleWorlds.Engine;
using TaleWorlds.Library;

#nullable disable
namespace TaleWorlds.MountAndBlade.View.MissionViews
{
  public class MissionBoundaryWallView : MissionView
  {
    public override void OnMissionScreenInitialize()
    {
      base.OnMissionScreenInitialize();
      foreach (ICollection<Vec2> boundaryPoints in (IEnumerable<ICollection<Vec2>>) this.Mission.Boundaries.Values)
        this.CreateBoundaryEntity(boundaryPoints);
    }

    private void CreateBoundaryEntity(ICollection<Vec2> boundaryPoints)
    {
      Mesh boundaryMesh = BoundaryWallView.CreateBoundaryMesh(this.Mission.Scene, boundaryPoints);
      if (!((NativeObject) boundaryMesh != (NativeObject) null))
        return;
      GameEntity empty = GameEntity.CreateEmpty(this.Mission.Scene);
      empty.AddMesh(boundaryMesh);
      empty.SetGlobalFrame(MatrixFrame.Identity);
      empty.Name = "boundary_wall";
      empty.SetMobility(GameEntity.Mobility.stationary);
      empty.EntityFlags |= EntityFlags.DoNotRenderToEnvmap;
    }
  }
}
